

import java.util.ArrayList;

public class Customer {
	
	private long cpr; // customers CPR number
	private int pin; // customers PIN code
	private String firstName; // customers first name
	private String lastName; // customers last name
	private ArrayList<Account> accountList; // list with customers 
											// accounts

public Customer(long theCpr, int thePin, 
				String theFirstName, String theLastName)
{
	cpr = theCpr;
	pin = thePin;
	firstName = theFirstName;
	lastName = theLastName;
	accountList = new ArrayList<Account>();
}

public String getFullName(){
	return String.format(firstName + " " + lastName);
}

public Account getAccount( int accountNumber )
{
   // loop through accounts searching for matching account number
   for ( Account currentAccount : accountList )
   {
      // return current account if match found
      if ( currentAccount.getAccountNumber() == accountNumber )
         return currentAccount;
   } // end for
   return null; // if no matching account was found, return null
} // end method getAccount

//returns account at given index
public Account getAccount2(int index)
{
	return accountList.get(index);
} //end method getAccount2

// adds new account to the accountList
public void addAccount(Account account)
{
	accountList.add(account);
} // end method addAccount

// deletes account from the accountList
public void deleteAccount(Account account)
{
	accountList.remove(account);
} // end method deleteAccount

// returns the size of the accountList
public int getAccountListSize()
{
	return accountList.size();
} //end method getAccountListSize

// returns cpr number
public long getCpr()
{
   return cpr;  
} // end method getCpr

// determines whether a user-specified PIN matches the customersPIN 
public boolean validatePIN( int userPIN )
{
   if ( userPIN == pin )
      return true;
   else
      return false;
} // end method validatePIN

//returns the accountList
public ArrayList<Account> getList()
{
	return accountList;
}//end method getList

}//end class Customer
